//
//  NSLayoutConstraint+Extensions.swift
//  SFDevFly
//
//  Created by shen on 2023/9/28.
//

import Foundation
import AppKit

extension NSLayoutConstraint {
    /**
      Change multiplier constraint

      - parameter multiplier: CGFloat
      - returns: NSLayoutConstraint
     */
    func setMultiplier(multiplier: CGFloat) -> NSLayoutConstraint {
        NSLayoutConstraint.deactivate([self])

        let newConstraint = NSLayoutConstraint(item: firstItem!, attribute: firstAttribute, relatedBy: relation, toItem: secondItem, attribute: secondAttribute, multiplier: multiplier, constant: constant)
        newConstraint.priority = priority
        newConstraint.shouldBeArchived = self.shouldBeArchived
        newConstraint.identifier = self.identifier

        NSLayoutConstraint.activate([newConstraint])
        return newConstraint
    }
}
